namespace Service.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreation : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.GamePlayer",
                c => new
                    {
                        GameId = c.Int(nullable: false),
                        PlayerId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.GameId, t.PlayerId })
                .ForeignKey("dbo.Games", t => t.GameId)
                .ForeignKey("dbo.Players", t => t.PlayerId)
                .Index(t => t.GameId)
                .Index(t => t.PlayerId);
            
            CreateTable(
                "dbo.Games",
                c => new
                    {
                        CaseId = c.Int(nullable: false, identity: true),
                    })
                .PrimaryKey(t => t.CaseId);
            
            CreateTable(
                "dbo.Players",
                c => new
                    {
                        PlayerId = c.Int(nullable: false, identity: true),
                        PlayerColor = c.Int(nullable: false),
                        Difficulty = c.Int(),
                    })
                .PrimaryKey(t => t.PlayerId);
            
            CreateTable(
                "dbo.PlayerHeuristic",
                c => new
                    {
                        PlayerId = c.Int(nullable: false),
                        HeuristicId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.PlayerId, t.HeuristicId })
                .ForeignKey("dbo.Heuristics", t => t.HeuristicId)
                .ForeignKey("dbo.Players", t => t.PlayerId)
                .Index(t => t.PlayerId)
                .Index(t => t.HeuristicId);
            
            CreateTable(
                "dbo.Heuristics",
                c => new
                    {
                        HeuristicId = c.Int(nullable: false),
                        HeuristicName = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.HeuristicId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.GamePlayer", "PlayerId", "dbo.Players");
            DropForeignKey("dbo.PlayerHeuristic", "PlayerId", "dbo.Players");
            DropForeignKey("dbo.PlayerHeuristic", "HeuristicId", "dbo.Heuristics");
            DropForeignKey("dbo.GamePlayer", "GameId", "dbo.Games");
            DropIndex("dbo.PlayerHeuristic", new[] { "HeuristicId" });
            DropIndex("dbo.PlayerHeuristic", new[] { "PlayerId" });
            DropIndex("dbo.GamePlayer", new[] { "PlayerId" });
            DropIndex("dbo.GamePlayer", new[] { "GameId" });
            DropTable("dbo.Heuristics");
            DropTable("dbo.PlayerHeuristic");
            DropTable("dbo.Players");
            DropTable("dbo.Games");
            DropTable("dbo.GamePlayer");
        }
    }
}
